package com.mc.servlet;

import com.mc.service.TeacherService;
import com.mc.service.impl.TeacherServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description 老师对象删除
 * @author wangcf
 * @date 2023/2/14 17:35
 * @version 1.0
 */
@WebServlet("/teacherdelete.action")
public class TeacherDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TeacherService teacherService=new TeacherServiceImpl();
        int tid=Integer.parseInt(req.getParameter("tid"));
        boolean flag=teacherService.delete(tid);
        System.out.println(flag);
        resp.sendRedirect("teacherlist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
